<?php

	// +----------------------------------------------------------------------
	// | 安装程序命令文件
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\common\command;

	use app\common\event\Setting as SettingEvent;
	use think\console\Command;
	use think\console\Input;
	use think\console\input\Argument;
	use think\console\input\Option;
	use think\console\Output;
	use think\facade\Config;

	class Install extends Command
	{
		protected function configure()
		{
			$this->setName('install')
				->addArgument('name', Argument::OPTIONAL, "参数名称")
				->addOption('value', null, Option::VALUE_REQUIRED, '配置值')
				->setDescription('Installation Program');
		}

		protected function execute(Input $input, Output $output)
		{
            $value = trim($input->getOption('value'));
            if (!isset($this->db['user'])) {
                fwrite(STDOUT, '请输入数据库配名' . PHP_EOL);
                $answer = strtolower(trim(fread(STDIN, 1024), PHP_EOL));
                fwrite(STDOUT, '请输入数据库密码' . PHP_EOL);
                $pass = strtolower(trim(fread(STDIN, 1024), PHP_EOL));
                $output->writeln("<info>{$answer}".$pass."</info>");
            }
            $output->writeln($value);
        }


	}